home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4014 / 4014.xpi / chrome / content / alternate-styles.js next >
Text File  |  2008-05-28  |  1KB  |  38 lines

  1. var lb2_alternateStyles = {
  2.   styles: ["domain-color","domain-strong","subdomain-inherit","pathFile-inherit","go-persist","segments-margin","breadcrumb-domain","breadcrumb-all"],
  3.   styleSheets: {},
  4.   prefs: Components.classes["@mozilla.org/preferences-service;1"]
  5.                    .getService(Components.interfaces.nsIPrefService)
  6.                    .getBranch("extensions.locationbar2.alternate.")
  7.                    .QueryInterface(Components.interfaces.nsIPrefBranch2),
  8.   init: function () {
  9.     this.prefs.addObserver("", this, false);
  10.     var ss = document.styleSheets;
  11.     for (var i = ss.length - 1; i >= 0; i--) {
  12.       var style = ss[i].href.match(/^chrome:\/\/locationbar2\/skin\/alternate\/(.+)\.css$/);
  13.       if (style) {
  14.         this.styleSheets[style[1]] = ss[i];
  15.         this.handlePref(style[1]);
  16.       }
  17.     }
  18.   },
  19.   observe: function (subject, topic, data) {
  20.     this.handlePref(data);
  21.   },
  22.   handlePref: function (style) {
  23.     if (style == "domain-color")
  24.       this.styleSheets[style].cssRules[1].style.setProperty("color", this.prefs.getCharPref(style) || "inherit", "");
  25.     else
  26.       this.styleSheets[style].disabled = !this.prefs.getBoolPref(style);
  27.   },
  28.   uninit: function() {
  29.     this.prefs.removeObserver("", this);
  30.   }
  31. };
  32.  
  33. window.addEventListener("load", function() {
  34.   lb2_alternateStyles.init();
  35. }, false);
  36. window.addEventListener("unload", function() {
  37.   lb2_alternateStyles.uninit();
  38. }, false);